/**
*   FuzzyEngine - an Simple flex framework 
*   Copyright (C) 2010 Constantin Aldea
*
*   This program is free software: you can redistribute it and/or modify
*   it under the terms of the GNU General Public License as published by
*   the Free Software Foundation, either version 3 of the License, or
*   (at your option) any later version.
*   This program is distributed in the hope that it will be useful,
*   but WITHOUT ANY WARRANTY; without even the implied warranty of
*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*   GNU General Public License for more details.
*
*   You should have received a copy of the GNU General Public License
*   along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
package fuzzy.penelope.core.dataservices.rest {
	import flash.utils.getDefinitionByName;
	import mx.core.Singleton;
	
	
/**
 *  This class is used to get a single instance of the  IServicefuzzy
 *  implementation.
 *  The IServicefuzzy  support  model standard for Flex applications in .
 *
 *  <p>A single instance of an IServicefuzzy implementation
 *  manages all httpservice calls
 *  for a Flex application.</p>
 *  
 *  @see com.flex.interfaces.IServicefuzzy
 *  @see com.flex.interfaces.ServiceImpl
 */
	public class Service 
	{
	//--------------------------------------------------------------------------
    //
    //  Class variables
    //
    //--------------------------------------------------------------------------



    /**
     *  @private
     *  The sole instance of the ServiceImpl.
     *  it would be great to use the interface but nowadays i don't have clear idea about the implementation
     */
		private static var instance:ServiceImpl;
		
		
	/**
     *  Gets the single instance of the ServiceImpl class.
     *  This object manages all ServiceImpl calls for a Flex application.
     *  
     *  @return An object implementing IServicefuzzy.
     */
		public static function getInstance():ServiceImpl{
			 if (!instance)
        {
            try
			{
				Singleton.registerClass("com.fuzzy.service::IServiceFuzzy", Class(getDefinitionByName("com.fuzzy.model::ServiceImpl")));
				instance = ServiceImpl(Singleton.getInstance("com.fuzzy.service::IServiceFuzzy"));
			}catch(e:Error)
			{
				
				instance = new ServiceImpl();
			}
        }
        
        return instance;
		}
		
		
	    //--------------------------------------------------------------------------
	    //
	    //  Constructor
	    //
	    //--------------------------------------------------------------------------
	

	}
}